package com.shadow.demo.info.excel;

import com.alibaba.excel.annotation.ExcelProperty;
import com.shadow.demo.data.info.entity.SiteInfoEntity;
import com.shadow.demo.excel.demo.v35.ToEntityConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;

/**
 * 禁止使用lombok的链式编程
 * */
@Data
@EqualsAndHashCode(callSuper = true)
public class SiteVO extends ToEntityConverter<SiteInfoEntity> implements Serializable {

    @ExcelProperty(value = "ID")
    private Long id;

    @NotEmpty(message = "名称不能为空")
    @ExcelProperty(value = "名称")
    private String title;

    @ExcelProperty(value = "类型")
    private String type;

    @ExcelProperty(value = "图标")
    private String icon;

    @NotBlank(message = "网址不能为空")
    @ExcelProperty(value = "网址")
    private String url;

    @ExcelProperty(value = "备注")
    private String description;

    @Override
    public SiteInfoEntity convert() {
        SiteInfoEntity entity = new SiteInfoEntity();
        BeanUtils.copyProperties(this, entity);
        return entity;
    }
}
